package br.indt.framework.ui.common;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

import br.indt.framework.ui.ImageLoader;

import com.nokia.mid.ui.VirtualKeyboard;

/**
 * Menu bar component for full touch devices.
 * 
 * @author Nokia Institute of Technology
 *
 */
public class MenuBarFullTouch extends MenuBar {

	private Image backButton = null;
	private Image backButtonDown = null;

	public MenuBarFullTouch(String name) {
		super(name);
		backButton = ImageLoader.load(ImageLoader.MENU_BAR_BACK_BUTTON);
		backButtonDown = ImageLoader.load(ImageLoader.MENU_BAR_BACK_BUTTON_DOWN);
	}

	public void paint(Graphics g, int x, int y, int maxWidth, int maxHeight) {
		if (rskItem == null || VirtualKeyboard.isVisible()) return;
		
		try {
			if (getMenuBarPosition() == 2) {
				//g.drawImage(backButtonDown, Display.getInstance().getWidth(), Display.getInstance().getHeight(), Graphics.BOTTOM | Graphics.RIGHT);
				g.drawImage(backButtonDown, 240, 400, Graphics.BOTTOM | Graphics.RIGHT);
			} else {
				//g.drawImage(backButton, Display.getInstance().getWidth(), Display.getInstance().getHeight(), Graphics.BOTTOM | Graphics.RIGHT);
				g.drawImage(backButton, 240, 400, Graphics.BOTTOM | Graphics.RIGHT);
			}
		} catch (Exception e) {
			//empty
		}
	}

	public int getHeight() {
		return height;
	}

	public void click(int x, int y) {
		try {
			if (rskItem != null) {
				menuItemListener.menuItemClicked(rskItem);
			}

			setMenuBarPosition(-1);

		} catch (Exception e) {
			// #ifdef LOGS
		//	Utils.log("[ERROR] MenuBarTouchType::click " + e);
			// #endif
		}
	}

	public void pressFire() {
	}
}